{template 'common/header'}
<ul class="nav nav-tabs">
    <li ><a href="{php echo url('sms/plan/list');}">监测通知列表</a></li>
    {if $id}
    <li class="active" ><a href="{php echo url('sms/plan/edit',array('id'=>$id));}">修改监测通知</a></li>
    {else}
    <li class="active" ><a href="{php echo url('sms/plan/add');}">增加监测通知</a></li>
    {/if}
</ul>
<div class="clearfix">
    <form class="form-horizontal form" action="{$url}" method="post" id="form1">
        <input type="hidden" name="id" value="{$row['id']}" />
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">通知名称</label>
            <div class="col-sm-5">
                <input type="text" id="title" name="title" class="form-control" placeholder="请输入名称" value="{$row['title']}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">发送方案</label>
            <div class="col-sm-5">
                <select name="gid" id="gid" class="form-control" onchange="change();" {if $id}disabled="true"{/if}>
                {loop $groups $r}
                <option value="{$r['id']}" {if $gid==$r['id']}selected{/if} >{$r['title']}</option>
                {/loop}
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">短信项目</label>
            <div class="col-sm-5">
                <table class="table">
                    <thead>
                    <tr>
                        <th>短信项目</th>
                        <th>输入内容</th>
                    </tr>
                    </thead>
                    <tbody >
                    {loop $values $item}
                    <tr>
                        <td >{$item['title']} </td>
                        <td style="text-align:center;width:50px;">
                            <input type="text" name="val_{$item['id']}" value="{$item['value']}" placeholder="请输入内容"/>
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>

        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">接收人员</label>
            <div class="col-sm-5">
                <table class="table ">
                <thead>
                <tr>
                    <th>用户名称</th>
                    <th>手机号码</th>
                    <th>单位职务</th>
                </tr>
                </thead>
                <tbody>
                {loop $selects $s}
                <tr>
                    <td>{$s['name']}</td>
                    <td>{$s['mobile']}</td>
                    <td>{$s['worktitle']}</td>
                </tr>
                {/loop}
                </tbody>
            </table>
            </div>
        </div>

        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
            <div class="col-sm-10">
                {if $row['status']==0}
                <button type="submit" class="btn btn-danger" name="submit" value="audit"><i class="fa fa-eye"></i> 提交审核</button>&nbsp;
                {/if}
                <button type="submit" class="btn btn-primary btn-default" name="submit" value="save"><i class="fa fa-save"></i>保存数据</button>
                <input type="hidden" name="token" value="{$_W['token']}" />
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    var change=function(){
        var gid=$('#gid').children('option:selected').val();
        window.location.href="{php echo url('sms/plan/add'); }gid="+gid;//页面跳转并传参
    }
    require(['jquery', 'util'], function($, u){

        $("#form1").submit(function(){
            if(!$("#title").val()) {
                u.message('方案名称为必填项，请返回修改！！', '', 'error');
                return false;
            }
            var isError = false;
            $('input[name^="val_"]').each(function(){
                if($.trim($(this).val()) == '') {
                    isError=true;
                }
            });
            if(isError ){
                u.message('短信项目没有输入内容.', '', 'error');
                return false;
            }
            return true;

        });



    });
</script>
{template 'common/footer'}